import { Constant } from "../../Constant";
import { Main } from "../../Main";
import StateBase from "../StateBase";

export default class LuckRecruitPrepareState extends StateBase {
    begin(preState: number): void {
        super.begin(preState);
       // console.log('LuckRecruitPrepareState state--begin');
        const main = this.getUserData() as Main;
        // 幸运招募准备状态的逻辑

        main.frontBg.playAnimation(Constant.FrontBgAni.Close, 0.2, () => {

            main.enterRolesRoles[2].setHide();
            main.scheduleOnce(() => {
                main.frontBg.playAnimation(Constant.FrontBgAni.Appear, 0.2, () => {
                    main.secRoundRoles.forEach(e => {
                        e.setActive(true);
                    });

                    main.roundOptions[3].active = true;
                    main.lightAnimation.setColor([3, 1, 3]);
                    main.roundTips[3].showStart(true);
                    main.secRoundRoles[2].setSelect();
                    main.secRoundRoles[2].setGray();
                    main.secRoundRoles?.forEach((note, index) => {
                        note.startGlow(() => {
                            main.lightAnimation.showLight(index);
                            if (index == 2) {
                                main.lightAnimation.setActive(2, false);
                            }
                        }, this)
                    })
                }, this);
            }, 1)
        }, this);
    }

    end(nextState: number): void {
        super.end(nextState);
      //  console.log('LuckRecruitPrepareState state--end');
    }
}
